import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import mutations from './mutations'
import actions from './actions'
import modules from './modules'

Vue.use(Vuex)
let currentUser = {
  userId: '',
  loginName: '',
  mobile: '',
  email: '',
  realName: '',
  headIco: '',
  companyName: '',
  legaler: '',
  status: '',
  super_id: '', // 上级账号id
  super_name: '', // 上级账号名称
  conf: {},
  roles: [], // 用户角色组
  powers: [], // 所有权限
  appPower: [], // app页面权限 97 按钮
  elementPower: [] // 页面元素id
}
if (localStorage.getItem('currentUser')) {
  currentUser = JSON.parse(localStorage.getItem('currentUser'))
}
let currentToken = ''
if (localStorage.getItem('token')) {
  currentToken = localStorage.getItem('token')
}
let state = {
  // 当前用户
  currentUser: currentUser,
  currentToken: currentToken, // 当前token
  activeMenu: {name: '', title: ''} // 当前活动导航
}
export default new Vuex.Store({
  state,
  getters,
  mutations,
  actions,
  modules,
  strict: process.env.NODE_ENV !== 'production'
})
